package com.x.uikit.page;

import android.app.Activity;

public class XPageManagerConfig {
    public final Activity activity;
    public final XPage rootPage;
    public IPageAnimator pageAnimator;
    public boolean fitSystemWindows = false;

    private XPageManagerConfig(Activity activity, XPage rootPage) {
        this.activity = activity;
        this.rootPage = rootPage;
    }


    public static Builder obtainBuilder() {
        return new Builder();
    }

    public static class Builder {
        private Activity activity;
        private XPage rootPage;
        private IPageAnimator pageAnimator;
        private boolean useSlidePageAnimator = true;
        private boolean fitSystemWindows = false;

        private Builder() {
        }

        public Builder setActivity(Activity activity) {
            this.activity = activity;
            return this;
        }

        public Builder setRootPage(XPage page) {
            this.rootPage = page;
            return this;
        }

        public Builder setFitsSystemWindows(boolean fitSystemWindows) {
            this.fitSystemWindows = fitSystemWindows;
            return this;
        }

        public Builder setPageAnimator(IPageAnimator animator) {
            this.pageAnimator = animator;
            useSlidePageAnimator = false;
            return this;
        }


        public XPageManagerConfig build() {
            if (activity == null) {
                throw new IllegalArgumentException("需要设置activity");
            }
            XPageManagerConfig config = new XPageManagerConfig(activity, rootPage);
            config.pageAnimator = pageAnimator;
            if (config.pageAnimator == null && useSlidePageAnimator) {
                config.pageAnimator = new XSlidePageAnimator();
            }
            config.fitSystemWindows = fitSystemWindows;
            return config;

        }

    }
}